package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	range
*/
public class range {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("range.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"range.out")));
		new range().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		int N = read(f);
		String[] g = new String[N];
		for (int i=0; i<N; i++) g[i] = f.readLine();
		
		boolean[][] b = new boolean[N][N];
		boolean[][] isSquare = new boolean[N][N];
		for (int i=0; i<N; i++) {
			for (int j=0; j<N; j++) {
				b[i][j] = g[i].charAt(j)=='1'? true : false;
				isSquare[i][j] = b[i][j];
			}
		}
		
		for (int size=2; size<=N; size++) {
			int count = 0;
			for (int i=0; i<=N-size; i++) {
				for (int j=0; j<=N-size; j++) {
					if (!isSquare[i][j]) continue;
					
					boolean test = true;
					for (int k=0; k<size; k++) {
						if (!b[i+k][j+size-1] || !b[i+size-1][j+k]) {
							test = false;
							break;
						}
					}
					if (test) {
						count++;
					}
					else {
						isSquare[i][j] = false;
					}
				}
			}
			if (count > 0) {
				out.println(size + " " + count);
			}
			else {
				break;
			}
		}
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	public int[] read(BufferedReader f, int N) throws IOException {
		String[] t = f.readLine().split(" ");
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
}
